package idv.loveloser.mobilemoodle;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class CourseContentAdapter extends BaseAdapter{
	private List<CourseContent> contents;
	private Context mContext;
	private LayoutInflater mInflater;
	public CourseContentAdapter(Context context){
		this.mContext=context;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return contents.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		CourseContentHolder holder =null;
		this.mInflater = LayoutInflater.from(mContext); 
		if (convertView == null) {
			holder=new CourseContentHolder();   
			convertView = mInflater.inflate(R.layout.course_contents_holder, null);
			holder.contentTypeTextView =(TextView) convertView.findViewById(R.id.contentTypeTextView);
			holder.introTextView =(TextView) convertView.findViewById(R.id.introTextView);
			holder.sectionTextView = (TextView) convertView.findViewById(R.id.sectionTextView);
			convertView.setTag(holder); 
		}else{
			holder = (CourseContentHolder)convertView.getTag(); 
		}
		holder.contentTypeTextView.setText(contents.get(position).getContentType());
		holder.introTextView.setText(contents.get(position).getContent());
		holder.sectionTextView.setText("Section "+contents.get(position).getSection());
		return convertView;
	}
	public List<CourseContent> getContents() {
		return contents;
	}
	public void setContents(List<CourseContent> contents) {
		this.contents = contents;
	}

}
